home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Messaging / OSL / CntxtOSL.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-22  |  7.4 KB  |  264 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CntxtOSL.h
  3.  
  4.     Contains:    Additions to the OSL interface for OpenDoc support.
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <10>     8/29/95    jpa        DescPtr --> AEDesc* for Univ Hdrs 2.1.
  13.                                     [1279173]
  14.          <9>     6/27/95    NP        1262792: new version of OSLObjectInit
  15.          <8>     5/25/95    jpa        Use #pragma import [1241078]
  16.          <7>     2/22/95    eeh        1222904: fix def of SetCurrentContext
  17.          <6>     1/25/95    eeh        1214783: fix def of kSwitchDescType
  18.          <5>      1/9/95    NP        1194880: private data change requested by
  19.                                     documentation.
  20.          <4>    11/15/94    NP        1196322-made functions non-pascal.
  21.          <3>     9/29/94    RA        1189812: Mods for 68K build.
  22.          <2>     8/19/94    NP        1181622: Ownership fix.
  23.          <1>     6/24/94    NP        first checked in
  24.         <13>      5/2/94    eeh        bug #1160654: various PPC native changes
  25.         <12>      2/9/94    NP        Tiger Team cleanup.
  26.         <11>      2/7/94    NP        Tiger Team doings.
  27.         <10>    10/22/93    NP        Added OSLCallObjectAccessor.
  28.          <9>    10/18/93    NP        Interface tweaks.
  29.          <8>    10/11/93    NP        Type name and parameter name tweaks.
  30.          <7>     9/24/93    JA        Minor syntactic tweaks for THINK C++.
  31.          <6>     9/20/93    NP        Added GetCurrentContext and
  32.                                     SetCurrentContext.
  33.          <5>      9/3/93    NP        Added "switch" descriptor type.
  34.          <4>     8/19/93    NP        Changed const error code to a #define.
  35.          <3>     8/18/93    NP        Mods for new context scheme.
  36.          <2>     8/16/93    NP        Added constant.
  37.          <1>     8/16/93    NP        first checked in
  38.  
  39.     To Do:
  40.     In Progress:
  41. */
  42.  
  43. /*———————————————————————————————————————————————————————————————————————————————————*/
  44. /*                                            
  45.     ©Apple Computer, Inc.  2/21/91             
  46.           All Rights Reserved.                
  47.  
  48. */
  49.  
  50. #ifndef _CNTXTOSL_
  51. #define _CNTXTOSL_
  52.  
  53. #ifndef __AEOBJECTS__
  54. #include <AEObjects.h>
  55. #endif
  56.  
  57. #define errNoDataHandle = -1731;
  58.  
  59. enum
  60. {
  61.     kSwitchDescType = 0x73776170 // 'swap'
  62. };
  63.  
  64. /************ Contexts ***************/
  65.  
  66. enum OSLCallbackSelector
  67. {
  68.     kCallbackFlagsGetter,
  69.     kObjectAccessor,
  70.     kCompareProc,
  71.     kCountProc,
  72.     kDisposeTokenProc,
  73.     kMarkProc,
  74.     kGetMarkTokenProc,
  75.     kAdjustMarksProc,
  76.     kGetErrDescProc
  77. };
  78. typedef enum OSLCallbackSelector OSLCallbackSelector;
  79.  
  80. typedef ProcPtr CallbackCallerProc;
  81.  
  82. #ifdef __cplusplus
  83. extern "C" {
  84. #endif
  85.  
  86. typedef
  87. CallbackCallerProc (*GetCallbackCallerProc)(OSLCallbackSelector whichCallback);
  88.  
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92.  
  93. struct OSLContext
  94. {
  95.     GetCallbackCallerProc    getCallerProc;
  96.     long                    refCon;
  97. };
  98. typedef struct OSLContext OSLContext;
  99.  
  100. /************ Tokens ***************/
  101.  
  102. typedef AEDesc OSLToken;
  103.  
  104. struct ContainedTokenRecord
  105. {
  106.     DescType    tokenClass;
  107.     OSLToken    token;
  108. };
  109. typedef struct ContainedTokenRecord ContainedTokenRecord, *ContainedTokenRecPtr,
  110.                     **ContainedTokenRecHandle;
  111.  
  112. /************ CallbackCallerProc real types ***************/
  113.  
  114. #ifdef __cplusplus
  115. extern "C" {
  116. #endif
  117.  
  118. typedef long (*CallbackFlagsGetter)(long contextRefCon);
  119.  
  120. typedef OSErr (*ObjectAccessorCaller)(DescType            desiredClass,
  121.                                         const OSLToken*    containerToken,
  122.                                         DescType        containerClass,
  123.                                         DescType        keyForm,
  124.                                         const AEDesc*    keyData,
  125.                                         OSLToken*        value,
  126.                                         Boolean*        procFound,
  127.                                         long            contextRefCon);
  128.  
  129. typedef OSErr (*CompareProcCaller)(DescType            oper,
  130.                                     const OSLToken*    obj1,
  131.                                     const OSLToken*    obj2,
  132.                                     Boolean*        result,
  133.                                     long            contextRefCon);
  134.  
  135. typedef OSErr (*CountProcCaller)(DescType            desiredType,
  136.                                     DescType        containerClass,
  137.                                     const OSLToken*    container,
  138.                                     long*            result,
  139.                                     long            contextRefCon);
  140.  
  141. typedef OSErr (*DisposeTokenProcCaller)(OSLToken*    unneededToken,
  142.                                         long        contextRefCon);
  143.  
  144. typedef OSErr (*GetMarkTokenProcCaller)(const OSLToken*    dContainerToken,
  145.                                             DescType        containerClass,
  146.                                             OSLToken*        result,
  147.                                             long            contextRefCon);
  148.  
  149. typedef OSErr (*GetErrDescProcCaller)(AEDesc**    appDescPtr,
  150.                                         long    contextRefCon);
  151.  
  152. typedef OSErr (*MarkProcCaller)(const OSLToken*        dToken,
  153.                                         const OSLToken*    markToken,
  154.                                         long            index,
  155.                                         long            contextRefCon);
  156.  
  157. typedef OSErr (*AdjustMarksProcCaller)(long            newStart,
  158.                                         long            newStop,
  159.                                         const OSLToken*    markToken,
  160.                                         long            contextRefCon);
  161.  
  162. #ifdef __cplusplus
  163. }
  164. #endif
  165.  
  166. /* typedefs providing type checking for procedure pointers */
  167. #if 0
  168. typedef pascal OSErr (*OSLAccessorProcPtr) ( DescType desiredClass,
  169.         const OSLToken *container, DescType containerClass, DescType form,
  170.         const AEDesc *selectionData, OSLToken *value, long LongInt ) ;
  171.  
  172. typedef pascal OSErr (*OSLCompareProcPtr)( DescType oper, const OSLToken *obj1,
  173.                                         const OSLToken *obj2, Boolean *result ) ;
  174. typedef pascal OSErr (*OSLCountProcPtr)( DescType desiredType,
  175.                                         DescType containerClass,
  176.                                         const OSLToken *container,
  177.                                         long *result ) ;
  178. typedef pascal OSErr (*OSLDisposeTokenProcPtr)( OSLToken *unneededToken ) ;
  179.  
  180. typedef pascal OSErr (*OSLGetMarkTokenProcPtr)( const OSLToken *dContainerToken,
  181.                                                 DescType containerClass,
  182.                                                 OSLToken *result ) ;
  183.  
  184.  
  185. typedef pascal OSErr (*OSLGetErrDescProcPtr)( AEDesc* *appDescPtr ) ;
  186.  
  187. /* Note: app is supposed to dispose of dToken after marking */
  188. typedef pascal OSErr (*OSLMarkProcPtr)( const OSLToken *dToken,
  189.                                         const OSLToken *markToken, long index ) ;
  190. typedef pascal OSErr (*OSLAdjustMarksProcPtr)( long newStart, long newStop,
  191.                                             const OSLToken *markToken ) ;
  192. #endif /* 0 */
  193.  
  194.  
  195. /*——————————————————————————————— PUBLIC PROCEDURES —————————————————————————————————*/
  196.  
  197. #ifdef __cplusplus
  198. extern "C" {
  199. #endif
  200.  
  201. #ifdef _PLATFORM_MACINTOSH_
  202. #pragma import on
  203. #endif
  204.  
  205. OSErr  OSLObjectInit( OSLContext* context ) ;
  206. /* Not done by inline, but by direct linking into code.  It sets up the pack
  207.   such that further calls can be via inline */
  208.  
  209.  
  210. OSErr  OSLResolve        (    const AEDesc    *objectSpecifier,
  211.                                       OSLToken        *theToken,
  212.                                     OSLContext*        startingContext);
  213.  
  214. OSErr OSLDisposeToken( OSLToken *theToken );
  215.  
  216. OSErr OSLCallObjectAccessor(DescType        desiredClass,
  217.                                     const AEDesc    *containerToken,
  218.                                     DescType        containerClass,
  219.                                     DescType        keyForm,
  220.                                     const AEDesc    *keyData,
  221.                                     AEDesc            *token);
  222.  
  223. OSErr GetCurrentContext( OSLContext* curContext );
  224. OSErr SetCurrentContext( OSLContext* curContext );
  225.  
  226. #ifdef __cplusplus
  227. }
  228. #endif
  229.  
  230. #ifdef _PLATFORM_MACINTOSH_
  231. #pragma import off
  232. #endif
  233.  
  234.  
  235. /*
  236. Here are the interfaces your callback procs must be written to:
  237.  
  238. pascal OSErr MyCompareProc( DescType comparisonOperator,
  239.                             const OSLToken *theObject, const OSLToken *descOrObj,
  240.                             Boolean *result ) ;
  241. pascal OSErr MyCountProc( DescType desiredType, DescType containerClass,
  242.                             const OSLToken *container, long *result:  ) ;
  243. pascal OSErr MyGetMarkToken( const OSLToken *containerToken,
  244.                                 DescType containerClass, OSLToken *result ) ;
  245. pascal OSErr MyMark( const OSLToken *theToken , const OSLToken *markToken,
  246.                         long markCount ) ;
  247. pascal OSErr MyAdjustMarks( long newStart, long newStop,
  248.                             const OSLToken *markToken ) ;
  249. pascal OSErr MyDisposeToken( OSLToken *unneededToken ) ;
  250. pascal OSErr MyGetErrDesc( AEDesc* *appDescPtr ) ;
  251.  
  252. pascal OSErr MyObjectAccessor( DescType desiredClass,
  253.                                 const OSLToken *containerToken,
  254.                                 DescType containerClass, DescType keyForm,
  255.                                 const AEDesc *keyData, OSLToken *theToken,
  256.                                 long *theRefcon ) ;
  257.  
  258. You'll probably want to have a number of these last ones.
  259. A proc that finds a line within a document should be installed with 'line' and 'docu'
  260. as the desiredClass and containerClass fields in the call to AEInstallObjectHandler().
  261. */
  262.  
  263. #endif /* _CNTXTOSL_ */
  264.